<template>
  <div>
    <!-- 搜索结果页-头部导航 -->
    <div class="search-result-container">
      <!-- 点击实现后退效果 -->
      <van-nav-bar title="搜索结果" left-arrow @click-left="$router.go(-1)" fixed />
    </div>
    <ArticleItem :dataList="list" v-for="item in list" :key="item.art_id" :artObj="item" :isShow="false"></ArticleItem>
  </div>
</template>

<script>
import { searchResultsAPI } from '@/api/index'
import ArticleItem from '@/components/ArticleItem.vue'
export default {
  data() {
    return {
      page: 1,
      // 文章列表
      list: []
    }
  },
  components: {
    ArticleItem
  },
  methods: {
    async getResultsList() {
      // this.$route.params.kw兄弟组件路由传参的值
      const res = await searchResultsAPI({ page: this.page, query: this.$route.params.kw })
      this.list = res.data.data.results
      // console.log(this.list)
    }
  },
  created() {
    this.getResultsList()
  }
}
</script>

<style lang="less" scoped>
.search-result-container {
  padding-top: 46px;
}
</style>
